package com.example.demo.controller;


import com.alibaba.fastjson.JSON;
import com.example.demo.entity.EmpInfo;
import com.example.demo.service.EmpInfoServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/index")
@Slf4j
public class EmpInfoContorller {

    @Autowired
    EmpInfoServiceImpl empInfoService;

    @RequestMapping("/insertRecod")
    public String addEmp(@RequestBody EmpInfo empInfo) {
        log.info("inset请求参数：{}", JSON.toJSONString(empInfo));
        try {
            empInfoService.insert(empInfo);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return "Success";
    }


    @RequestMapping("/updateRecod")
    public String updateRecod(EmpInfo empInfo) {
        log.info("update请求参数：{}", JSON.toJSONString(empInfo));
        try {
            empInfoService.updateRecod(empInfo);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return "Success";
    }


}
